package com.itheima.order.controller;

import com.itheima.cloud.pojo.Order;
import com.itheima.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    Environment environment;

    @GetMapping("findOrderByUserId/{id}")
    public List<Order> findOrderByUserId(@PathVariable("id") String username) {
//        int i = 10 / 0;
        System.out.println("PORT= "+environment.getProperty("server.port"));
        return orderService.findOrderByUserId(username);


    }

}
